package com.lsh.rabbitmqutil;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

/**
 * @author ：LiuShihao
 * @date ：Created in 2020/8/19 5:28 下午
 * @desc ：如果消息未能投递到目标 queue 里将触发回调 returnCallback ，
 * 一旦向 queue 投递消息未成功，这里一般会记录下当前消息的详细投递数据，方便后续做重发或者补偿等操作。
 */
@Slf4j
//@Component
public class ReturnCallbackService implements RabbitTemplate.ReturnCallback {

    @Override
    public void returnedMessage(Message message, int replyCode, String replyText, String exchange, String routingKey) {
        log.info("returnedMessage ===> replyCode="+replyCode+" ,replyText="+replyText+" ,exchange="+exchange+" ,routingKey="+routingKey);
    }
}

